% \iffalse meta-comment -------------------------------------------------------
% Copyright 2015 Matthias Vogelgesang and the LaTeX community. A full list of
% contributors can be found at
%
%     https://github.com/matze/mtheme/graphs/contributors
%
% and the original template was based on the HSRM theme by Benjamin Weiss.
%
% This work is licensed under a Creative Commons Attribution-ShareAlike 4.0
% International License (https://creativecommons.org/licenses/by-sa/4.0/).
% ------------------------------------------------------------------------- \fi
% \iffalse
%<*package>
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{beamerthememetropolis}
  [2017/01/23 v1.2 Metropolis Beamer theme]
%</package>
% \fi
% \CheckSum{0}
% \StopEventually{}
% \iffalse
%<*package>
% ------------------------------------------------------------------------- \fi
%
% \subsection{\themename parent theme}
%
% The primary job of this package is to load the component sub-packages of the
% \themename theme and route the theme options accordingly. It also
% provides some custom commands and environments for the user.
%
%
%
% \subsubsection{Package dependencies}
%
%    \begin{macrocode}
\RequirePackage{etoolbox}
\RequirePackage{pgfopts}
%    \end{macrocode}
%
%
%
% \subsubsection{Options}
%
% Most options are passed off to the component sub-packages.
%
%    \begin{macrocode}
\pgfkeys{/metropolis/.cd,
  .search also={
    /metropolis/inner,
    /metropolis/outer,
    /metropolis/color,
    /metropolis/font,
  }
}
%    \end{macrocode}
%
% \begin{macro}{titleformat plain}
%    Controls the formatting of the text on standout ``plain'' frames.
%    \begin{macrocode}
\pgfkeys{
  /metropolis/titleformat plain/.cd,
    .is choice,
    regular/.code={%
      \let\metropolis@plaintitleformat\@empty%
      \setbeamerfont{standout}{shape=\normalfont}%
    },
    smallcaps/.code={%
      \let\metropolis@plaintitleformat\@empty%
      \setbeamerfont{standout}{shape=\scshape}%
    },
    allsmallcaps/.code={%
      \let\metropolis@plaintitleformat\MakeLowercase%
      \setbeamerfont{standout}{shape=\scshape}%
      \PackageWarning{beamerthememetropolis}{%
        Be aware that titleformat plain=allsmallcaps can lead to problems%
      }
    },
    allcaps/.code={%
      \let\metropolis@plaintitleformat\MakeUppercase%
      \setbeamerfont{standout}{shape=\normalfont}%
      \PackageWarning{beamerthememetropolis}{%
        Be aware that titleformat plain=allcaps can lead to problems%
      }
    },
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{titleformat}
%    Sets a standard format for titles, subtitles, section titles, frame
%    titles, and the text on standout ``plain'' frames.
%    \begin{macrocode}
\pgfkeys{
  /metropolis/titleformat/.code=\pgfkeysalso{
      font/titleformat title=#1,
      font/titleformat subtitle=#1,
      font/titleformat section=#1,
      font/titleformat frame=#1,
      titleformat plain=#1,
    }
}
%    \end{macrocode}
% \end{macro}
%
% For backwards compatibility with earlier betas of the theme, we implement
% deprecated option names as aliases to the corresponding |key=value| options.
%
%    \begin{macrocode}
\pgfkeys{/metropolis/.cd,
  usetitleprogressbar/.code=\pgfkeysalso{outer/progressbar=frametitle},
  noslidenumbers/.code=\pgfkeysalso{outer/numbering=none},
  usetotalslideindicator/.code=\pgfkeysalso{outer/numbering=fraction},
  nosectionslide/.code=\pgfkeysalso{inner/sectionpage=none},
  darkcolors/.code=\pgfkeysalso{color/background=dark},
  blockbg/.code=\pgfkeysalso{color/block=fill, inner/block=fill},
}
%    \end{macrocode}
%
% Set default values for options.
%
%    \begin{macrocode}
\newcommand{\metropolis@setdefaults}{
  \pgfkeys{/metropolis/.cd,
    titleformat plain=regular,
  }
}
%    \end{macrocode}
%
% To avoid generating externalized figures of the progressbar we have to disable
% them with ``tikzexternalenable'' and ``tikzexternaldisable''. However, if the
% ``external'' libray is not loaded we would get undefined control sequence
% problems, hence we define them as no-ops if they are not defined yet.
%
%    \begin{macrocode}
\providecommand{\tikzexternalenable}{}
\providecommand{\tikzexternaldisable}{}
%    \end{macrocode}
%
% \subsubsection{Component sub-packages}
%
% Having processed the options, we can now load the component sub-packages of
% the theme.
%
%    \begin{macrocode}
\useinnertheme{metropolis}
\useoutertheme{metropolis}
\usecolortheme{metropolis}
\usefonttheme{metropolis}
%    \end{macrocode}
%
% The |tol| theme for |pgfplots| is only loaded if |pgfplots| is used.
%
%    \begin{macrocode}
\AtEndPreamble{%
  \@ifpackageloaded{pgfplots}{%
    \RequirePackage{pgfplotsthemetol}
  }{}
}
%    \end{macrocode}
%
%
%
% \subsubsection{Custom commands}
%
% The parent theme defines custom commands as their proper usage may depend
% on multiple sub-packages.
%
% \begin{macro}{\metroset}
%    Allows the user to change options midway through a presentation.
%    \begin{macrocode}
\newcommand{\metroset}[1]{\pgfkeys{/metropolis/.cd,#1}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\plain}
%   Creates a plain frame with dark background, suitable for displaying images
%   or a few words. The format of the text can be set with the
%   |titleformat plain| option.
%    \begin{macrocode}
\def\metropolis@plaintitleformat#1{#1}
\newcommand{\plain}[2][]{%
  \PackageWarning{beamerthememetropolis}{%
    The syntax `\plain' may be deprecated in a future version of Metropolis.
    Please use a frame with [standout] instead.
  }
  \begin{frame}[standout]{#1}
    \metropolis@plaintitleformat{#2}
  \end{frame}
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\mreducelistspacing}
%    \begin{macrocode}
\newcommand{\mreducelistspacing}{\vspace{-\topsep}}
%    \end{macrocode}
% \end{macro}
%
%
%
% \subsubsection{Process package options}
%
%    \begin{macrocode}
\metropolis@setdefaults
\ProcessPgfOptions{/metropolis}
%    \end{macrocode}
%
% \iffalse
%</package>
% \fi
% \Finale
\endinput
